package com.ah.shanxi_demo.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zt 2020/8/19
 */
public enum PolicyCommonEnum implements PolicyCommonInterface {

    //策略状态
    STATUS_INIT("0", "未完成"),
    STATUS_SUCCESS("1", "上传成功"),
    STATUS_UNDONE("2", "上传中"),
    STATUS_FAIL("-1", "上传失败"),

    //日志类型
    LOG_TYPE_EVENT("event", "安全事件源日志追溯"),
    LOG_TYPE_ALARM("alarm", "关键设备日志"),
    LOG_TYPE_DB("db", "数据库"),

    //策略类型
    POLICY_TYPE_EVENT_ID("eventID", "安全事件源日志追溯"),
    POLICY_TYPE_1("ALM-01-1", "边界防护类"),
    POLICY_TYPE_2("ALM-01-2", "入侵防范类"),
    POLICY_TYPE_3("ALM-01-3", "病毒防护类"),
    POLICY_TYPE_4("ALM-01-4", "安全准入类"),
    POLICY_TYPE_5("ALM-01-5", "防病毒软件类"),
    POLICY_TYPE_ALARM("alarm", "数据库审计告警日志"),

    ;
    private String key;
    private String value;

    final static Map<String, PolicyCommonEnum> cache = new HashMap<>(values().length);

    static {
        for (PolicyCommonEnum policyCommonEnum : values()) {
            cache.put(policyCommonEnum.key, policyCommonEnum);
        }
    }


    PolicyCommonEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static PolicyCommonEnum convert(String key) {
        PolicyCommonEnum type = cache.get(key);
        return type;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public Integer getKeyInt() {
        return Integer.parseInt(key);
    }
}
